﻿@model CNRegex.Web.Models.ModelBlogSearch

@{
    ViewBag.Title = "Search";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="@Url.Content("~/Content/css/BlogSearch.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.highlight.js")" type="text/javascript"></script>
<script type="text/javascript">

	$(document).ready(
		function () {
			var len = document.getElementById("pagination-flickr").getElementsByTagName("li").length;
			var width = len * 20 + 80;
			var keywords = jQuery.trim($("#SearchBlog_Keywords").val());
			$("#pagination-flickr").css("width", width + "px");
			if (keywords != "") {
				$('#blogsList').removeHighlight().highlight(keywords);
			}
		}
	);
	function search(order,aId) {
		var keywords = jQuery.trim($("#SearchBlog_Keywords").val());
		var catalogID = $("#SearchBlog_UserBlogCatalogID").val();
		var direction="";
		if (aId != undefined) {
			direction = Math.abs(parseInt($("#" + aId).attr("order")) - 1);
			direction = isNaN(direction) ? 1 : direction;
		}
		window.location.href = "/blog/search/?c=" + catalogID + "&k=" + escape(keywords) + (order == undefined ? "" : "&ok=" + order) + (aId == undefined ? "" : "&d=" + direction);
	}
	function searchKeyPress() {
		if (window.event)
		{
			if (e.keyCode == 13)
				search();
		}
		else if (e.which)
		{
			if (e.which == 13)
				search();
		}
	}

</script>
<h2 class="t_h2">文章检索</h2>
<div class="bs_left_content">
	<div class="bs_search_condition">
		<span class="bs_span_key">关键字:</span>
		@Html.TextBoxFor(x => x.SearchBlog.Keywords)
		<span class="bs_span_catalog">分类:</span>
		@Html.DropDownListFor(x => x.SearchBlog.UserBlogCatalogID, Model.BlogCatalog)
		<input type="button" value="搜索" class="bs_btn_search" onclick="return search();" onkeydown="return searchKeyPress(event);" />
	</div>
	<div class="bs_order">
		<a href="javascript:search('date','aDate')" id="aDate" @(Model.SearchBlog.OrderCreateDate == null ? "" : string.Format("order={0}", (int)Model.SearchBlog.OrderCreateDate))>时间<span class="bs_direction">@(Model.SearchBlog.OrderCreateDate == null ? "" : Model.SearchBlog.OrderCreateDate==CNRegex.Enum.EnumOrder.ASC?"↑":"↓")</span></a>
		<a href="javascript:search('recommend','aRecommend')" id="aRecommend" @(Model.SearchBlog.OrderRecommend == null ? "" : string.Format("order={0}", (int)Model.SearchBlog.OrderRecommend))>推荐<span class="bs_direction">@(Model.SearchBlog.OrderRecommend == null ? "" : Model.SearchBlog.OrderRecommend == CNRegex.Enum.EnumOrder.ASC ? "↑" : "↓")</span></a>
		<a href="javascript:search('click','aClick')" id="aClick" @(Model.SearchBlog.OrderClick == null ? "" : string.Format("order={0}", (int)Model.SearchBlog.OrderClick))>点击<span class="bs_direction">@(Model.SearchBlog.OrderClick == null ? "" : Model.SearchBlog.OrderClick == CNRegex.Enum.EnumOrder.ASC ? "↑" : "↓")</span></a>
	</div>
	<div class="bs_top_pagination">
		@{
		Html.RenderPartial("/Views/Controls/Paginate.cshtml",Model.ExPaginate);
		}
	</div>
	<div class="clear"></div>
	<hr class="bs_line" />
	<div class="blogs_list" id="blogsList">
		<ul>
			@for (int i = 0; i < Model.Blogs.Count; i++)
   {
				<li>
					<div class="blog_upup" onclick="recommend('/blog/recommend/','@Model.Blogs[i].ID','spanRecommendTimes','@i','recommendBlogCookie','您已经推荐过此文章,谢谢.')">
						<span @Html.Raw(string.Format("id=spanRecommendTimes{0}",i))>@(Model.Blogs[i].Recommend == null ? "0" : Model.Blogs[i].Recommend.Value.ToString())</span>
					</div>
					<div class="blog_item">
						<div class="blog_title">
							<a href="/blog/detail/@Model.Blogs[i].ID">@Model.Blogs[i].Title</a>
						</div>
						<div class="blog_summary">
							@Model.Blogs[i].Summery<text> ...</text>
						</div>
						<div class="blog_tool">
							<a href="/@Model.Blogs[i].RegexUserName" class="blog_author">
								<span>@Model.Blogs[i].RegexUserName</span>
							</a>
							<a href="/blog/detail/@Model.Blogs[i].ID" class="blog_write_time">
								<span>@Model.Blogs[i].CreateDate.Value.ToString("yyyy/MM/dd")</span>
							</a>
							<a href="/blog/detail/@Model.Blogs[i].ID" class="blog_comments">
								<span>评论(@Model.Blogs[i].Comments)</span>
							</a>
							-
							<a href="/blog/detail/@Model.Blogs[i].ID" class="blog_click">
								<span>阅读(@(Model.Blogs[i].ClickCount??0))</span>
							</a>
							-
							<a href="/blog/detail/@Model.Blogs[i].ID" class="blog_catalog">
								<span>分类 - @Model.Blogs[i].RegexUserBlogCatalogName</span>
							</a>
						</div>
					</div>
				</li>
   }
		</ul>
		
	</div>
</div>
